<?php
/**
* @package		TSB
* @license		GNU/GPL, see LICENSE.php
*/

jimport('joomla.application.component.view');

/**
 * HTML View class for the TSB Component
 *
 * @package		TSB
 */
class TSBViewUsers extends JView {
	function display($tpl = null) {
		$task = JRequest :: getVar('task');

		switch ($task) {
			case 'edit':
				//get all userroles from Request which is retrived from User Controller Edit function
				$roles = JRequest :: getVar('roles');
				$users = & $this->get('Data');
				JToolBarHelper :: title(JText::_('PROJECT NAME').' - '.JText :: _('USERS') . ': <small><small>[ ' . JText :: _('Edit') . ' ]</small></small>', 'ju_tsb');
				JToolBarHelper :: save();
				// for existing items the button is renamed `close`
				JToolBarHelper :: cancel('cancel', 'Close');
				$this->assignRef('users', $users);

				//Chuyen userroles cho Template
				$this->assignRef('roles', $roles);
				break;

			case 'add':
				//get all userroles from Request which is retrived from User Controller Edit function
				$roles = JRequest :: getVar('roles');
				//get all joomla users from DB
				$system_users = JRequest :: getVar('system_users');
				JToolBarHelper :: title(JText::_('PROJECT NAME').' - '.JText :: _('USERS') . ': <small><small>[ ' . JText :: _('New') . ' ]</small></small>', 'ju_tsb');
				JToolBarHelper :: save();
				// for existing items the button is renamed `close`
				JToolBarHelper :: cancel('cancel', 'Close');
				//Chuyen userroles cho Template
				$this->assignRef('roles', $roles);
				//Chuyen system_users cho Template
				$this->assignRef('system_users', $system_users);
				break;

			default:
				JToolBarHelper :: title(JText::_('PROJECT NAME').' - '.JText :: _('USERS MANAGER'), 'ju_tsb');
				JToolBarHelper :: deleteList(JText :: _('ARE YOU SURE')); //param: 1: message 2: task to do 3: Label of the button
				JToolBarHelper :: editListX();
				JToolBarHelper::addNewX();

				// Get data from the model
				$items = & $this->get('AllData');

				$this->assignRef('items', $items);

				break;
		}

		parent :: display($tpl);
	}

}
?>
